home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / metamail / contrib / ServiceMail / src / services / uudecode.tcl < prev    next >
Encoding:
Text File  |  1993-05-07  |  885 b   |  27 lines

  1. # uudecode
  2. #
  3. # 25-Jun-92 weber@eitech.com updated for new parameter format
  4. # 29-May-92 weber@eitech.com
  5. #
  6. # This service scans through a message body for uudecode source, and
  7. # sends what it found back to the requestor.  If the input is a multipart, it
  8. # scans through the last body in the multipart.
  9. #
  10. proc uudecode {switches envelope inputs} {
  11.       if {[getfield $inputs TYPE] == "multipart"} {
  12.     set parts [getfield $inputs PARTS]
  13.     return [uudecode $switches $envelope [lindex $parts [expr [llength $parts] - 1]]]
  14.       } {
  15.     set src [getfield $inputs FILE]
  16.         exec awk "/^begin /,/^end\$/" $src | uudecode
  17.     set sink [glob [exec awk "/^begin /{print \$3}" $src]]
  18.         if {[regexp "(.*)\.Z$" $sink match submatch]} {
  19.       exec uncompress $sink
  20.       setfield response FILE $submatch
  21.     } {
  22.       setfield response FILE $sink
  23.     }
  24.     return [mailout [turnaround $envelope] $response]
  25.       }
  26. }
  27.